﻿<%@ Page Language="C#" MasterPageFile="~/Manager.master" AutoEventWireup="true" CodeFile="OrderDetailApp.aspx.cs"
    Inherits="Manager_OrderApp_OrderDetailApp" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div>
        <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
            <tr>
                <td>
                    <table border="0" cellpadding="0" cellspacing="0" class="tbl_News" width="100%">
                        <tr>
                            <td class="td_Content_590">
                                <table cellpadding="0" cellspacing="0" style="padding-right: 25px; padding-left: 20px"
                                    width="100%">
                                    <tr>
                                        <td align="center" height="45" valign="middle">
                                            <asp:Label ID="Label1" runat="server" CssClass="lbl_TitileNews_590" Text="CHI TIẾT ĐƠN ĐẶT HÀNG"
                                                Font-Bold="True" Font-Names="Tahoma" Font-Size="17px"></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                                <tr>
                                                    <td valign="top">
                                                        <table border="0" cellpadding="2" cellspacing="0">
                                                            <tr>
                                                                <td style="height: 14px">
                                                                    <img alt="Tạo user mới" src="../../Images/Icon/add-user-icon.png" onclick="fnAddUser()"
                                                                        title="Chọn User" style="cursor: pointer" width="30px" height="30px" /><img alt="chọn user đã tồn tại"
                                                                            src="../../Images/Icon/user-icon.png" title="Chọn User" style="cursor: pointer"
                                                                            onclick="fnViewUser()" width="30px" height="30px" />&nbsp;
                                                                </td>
                                                                <td style="height: 14px" align="left" valign="bottom">
                                                                    <asp:Label ID="Label3" runat="server" Text="Thông tin của bạn" Font-Size="14px" Font-Bold="True"></asp:Label></td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <table border="0" cellpadding="2" cellspacing="0" style="width: 100%">
                                                            <tr>
                                                                <td align="right" class="td_GuestInfo" nowrap="nowrap" style="width: 87px">
                                                                    Họ tên:</td>
                                                                <td align="left" nowrap="nowrap">
                                                                    <asp:TextBox ID="txtHoTen" runat="server" ValidationGroup="grCustomer" Width="222px"
                                                                        CssClass="txt_Product" BackColor="#EAEAEA" ReadOnly="True"></asp:TextBox>
                                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtHoTen"
                                                                        ErrorMessage="Nhập vào tên khách hàng" ForeColor="Red" ValidationGroup="grCustomer">*</asp:RequiredFieldValidator></td>
                                                            </tr>
                                                            <tr style="color: #000000">
                                                                <td align="right" class="td_GuestInfo" nowrap="nowrap" style="width: 87px">
                                                                    Địa chỉ:</td>
                                                                <td align="left" nowrap="nowrap">
                                                                    <asp:TextBox ID="txtDiaChi" runat="server" CssClass="txt_Product" ValidationGroup="grCustomer"
                                                                        Width="224px" BackColor="#EAEAEA" ReadOnly="True"></asp:TextBox>
                                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtDiaChi"
                                                                        ErrorMessage="Nhập vào địa chỉ" ForeColor="Red" ValidationGroup="grCustomer">*</asp:RequiredFieldValidator></td>
                                                            </tr>
                                                            <tr>
                                                                <td align="right" class="td_GuestInfo" nowrap="nowrap" style="width: 87px">
                                                                    Điện thoại:</td>
                                                                <td align="left" nowrap="nowrap">
                                                                    <asp:TextBox ID="txtDienThoai" runat="server" CssClass="txt_Product" ValidationGroup="grCustomer"
                                                                        BackColor="#EAEAEA" ReadOnly="True"></asp:TextBox>
                                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtDienThoai"
                                                                        ErrorMessage="Nhập vào điện thoại" ForeColor="Red" ValidationGroup="grCustomer">*</asp:RequiredFieldValidator>
                                                                    <asp:Label ID="lblBirthDay" runat="server" Text="" Visible="false"></asp:Label>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td align="right" class="td_GuestInfo" nowrap="nowrap" style="width: 87px">
                                                                    Email:</td>
                                                                <td align="left" nowrap="nowrap">
                                                                    <asp:TextBox ID="txtEmail" runat="server" CssClass="txt_Product" onblur="fnCheckEmail(this.value)"
                                                                        onkeyup="fnHideImgEmail()" ValidationGroup="grCustomer" Width="203px" BackColor="#EAEAEA"
                                                                        ReadOnly="True"></asp:TextBox>&nbsp;
                                                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
                                                                        ErrorMessage="Yêu cầu nhập chính xác địa chỉ Email" ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                                                        ValidationGroup="grCustomer">*</asp:RegularExpressionValidator>
                                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator51" runat="server" ControlToValidate="hidEmail"
                                                                        CssClass="valid_common" ErrorMessage="Email này đã được sử dụng" InitialValue="0"
                                                                        ValidationGroup="grCustomer"> &nbsp;</asp:RequiredFieldValidator>
                                                                    <img id="imgStateEmail" border="0" src="../../Images/Icon/spinner.gif" style="visibility: hidden" />
                                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator52" runat="server" ControlToValidate="hidEmail"
                                                                        CssClass="valid_common" ErrorMessage="Đang xử lý..." ValidationGroup="grCustomer">Đang xử lý...</asp:RequiredFieldValidator>
                                                                    <asp:TextBox ID="hidEmail" runat="server" CssClass="cssHidden" Text="1" Width="5px"></asp:TextBox>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td align="right" class="td_GuestInfo" nowrap="nowrap" style="width: 87px">
                                                                    Tỉnh, Thành phố:</td>
                                                                <td align="left" nowrap="nowrap">
                                                                    <table border="0" cellpadding="0" cellspacing="0">
                                                                        <tr>
                                                                            <td>
                                                                                <asp:DropDownList ID="ddlPlace" runat="server" Enabled="False">
                                                                                </asp:DropDownList>
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td align="right" class="td_GuestInfo" nowrap="nowrap" style="width: 87px">
                                                                    <asp:Label ID="Label2" runat="server" Text="Mã số thuế:"></asp:Label></td>
                                                                <td align="left" nowrap="nowrap">
                                                                    <asp:TextBox ID="txtTaxNo" runat="server" CssClass="txt_Product" ValidationGroup="grCustomer"
                                                                        Width="222px" BackColor="#EAEAEA" ReadOnly="True"></asp:TextBox></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="td_GuestInfo" nowrap="nowrap" style="width: 87px">
                                                                </td>
                                                                <td align="left" nowrap="nowrap">
                                                                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="Red" ValidationGroup="grCustomer"
                                                                        ShowMessageBox="True" ShowSummary="False" />
                                                                </td>
                                                            </tr>
                                                        </table>
                                                        <br />
                                                    </td>
                                                </tr>
                                            </table>
                                            <div align="center" width="100%">
                                                <table border="0" cellpadding="2" cellspacing="0" width="100%">
                                                    <tr>
                                                        <td align="right">
                                                            <input id="hidUSD" type="hidden" runat="server" />
                                                            <asp:Label ID="lblUSD" runat="server"></asp:Label></td>
                                                    </tr>
                                                    <tr>
                                                        <td align="center" valign="top">
                                                            <asp:GridView ID="grv_Master" runat="server" AutoGenerateColumns="False" Width="100%"
                                                                CellPadding="3" BorderWidth="1px" OnRowDataBound="grv_Master_RowDataBound" BorderColor="#407db3"
                                                                DataKeyNames="PDID">
                                                                <Columns>
                                                                    <asp:TemplateField HeaderText="M&#227; sản phẩm">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblMaSP" runat="server" Text='<%# Eval("PDID") %>'></asp:Label>
                                                                        </ItemTemplate>
                                                                        <ItemStyle CssClass="cssBorderGrv" HorizontalAlign="Center" />
                                                                        <HeaderStyle CssClass="cssBorderGrv" HorizontalAlign="Center" VerticalAlign="Middle"
                                                                            Wrap="False" Width="5%" />
                                                                        <FooterStyle CssClass="cssBorderGrv" />
                                                                    </asp:TemplateField>
                                                                    <asp:TemplateField HeaderText="T&#234;n sản phẩm">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblTenSP" runat="server" Text='<%# Eval("PDName") %>' Width="40%"></asp:Label>
                                                                        </ItemTemplate>
                                                                        <ItemStyle CssClass="cssBorderGrv" HorizontalAlign="Left" />
                                                                        <HeaderStyle CssClass="cssBorderGrv" HorizontalAlign="Left" VerticalAlign="Middle"
                                                                            Wrap="False" />
                                                                        <FooterStyle CssClass="cssBorderGrv" />
                                                                    </asp:TemplateField>
                                                                    <asp:TemplateField HeaderText="Số lượng">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="txtSoLuong" runat="server" Style="vertical-align: middle; text-align: center"
                                                                                Text='<%# LoadQuantity(Eval("PDID").ToString()) %>'></asp:Label>
                                                                        </ItemTemplate>
                                                                        <ItemStyle CssClass="cssBorderGrv" HorizontalAlign="Center" Width="4%" />
                                                                        <HeaderStyle CssClass="cssBorderGrv" HorizontalAlign="Center" VerticalAlign="Middle"
                                                                            Wrap="False" />
                                                                        <FooterStyle CssClass="cssBorderGrv" />
                                                                    </asp:TemplateField>
                                                                    <asp:TemplateField HeaderText="Giá">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblDonGia" runat="server" Text='<%# Eval("Price") %>'></asp:Label>
                                                                            <input type="hidden" value='<%# Eval("Price") %>' id="hidPrice" runat="server" />
                                                                            <asp:Label ID="lblKindMoney" runat="server" Text='<%# Eval("Rate") %>'></asp:Label>
                                                                            <input id="hidKindNo" runat="server" type="hidden" value='<%# Eval("KindNo") %>' />
                                                                            <asp:TextBox ID="txtSaleOfPrice" runat="server" Text='<%# Eval("DiscountPrice") %>'
                                                                                Visible="false"></asp:TextBox>
                                                                            <input id="hidQuantity" runat="server" type="hidden" value='<%# Eval("Quantity") %>' />
                                                                        </ItemTemplate>
                                                                        <ItemStyle CssClass="cssBorderGrv" HorizontalAlign="Right" Wrap="false" />
                                                                        <HeaderStyle CssClass="cssBorderGrv" HorizontalAlign="Center" VerticalAlign="Middle"
                                                                            Wrap="False" Width="10%" />
                                                                        <FooterStyle CssClass="cssBorderGrv" />
                                                                    </asp:TemplateField>
                                                                    <asp:TemplateField HeaderText="Th&#224;nh tiền(VNĐ)">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblThanhTien" runat="server" Text='<%# Eval("Total") %>'></asp:Label>
                                                                        </ItemTemplate>
                                                                        <ItemStyle CssClass="cssBorderGrv" HorizontalAlign="right" />
                                                                        <HeaderStyle CssClass="cssBorderGrv" HorizontalAlign="Center" VerticalAlign="Middle"
                                                                            Wrap="False" Width="5%" />
                                                                        <FooterStyle CssClass="cssBorderGrv" />
                                                                    </asp:TemplateField>
                                                                    <asp:TemplateField HeaderText="Ghi chú">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblNoteDetail" runat="server" Text='<%# Eval("NoteDetail") %>'></asp:Label>
                                                                        </ItemTemplate>
                                                                        <ItemStyle CssClass="cssBorderGrv" HorizontalAlign="right" />
                                                                        <HeaderStyle CssClass="cssBorderGrv" HorizontalAlign="Center" VerticalAlign="Middle"
                                                                            Wrap="False" Width="10%" />
                                                                        <FooterStyle CssClass="cssBorderGrv" />
                                                                    </asp:TemplateField>
                                                                </Columns>
                                                                <EmptyDataTemplate>
                                                                    <div align="center">
                                                                        <asp:Label ID="Label1" runat="server" Text="Chưa có sản phẩm nào trong giỏ hàng của bạn"
                                                                            CssClass="lbl_TextDefault"></asp:Label>
                                                                    </div>
                                                                </EmptyDataTemplate>
                                                                <RowStyle CssClass="gvRowStyle" />
                                                                <AlternatingRowStyle CssClass="gvAlternatingRowStyle" />
                                                                <HeaderStyle CssClass="gvHeader" VerticalAlign="Middle" Wrap="False" />
                                                                <FooterStyle CssClass="gv_FooterBasket" BackColor="paleturquoise" />
                                                            </asp:GridView>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="center" valign="top">
                                                            <table border="0" bordercolor="#407db3" cellpadding="0" cellspacing="0" style="border-collapse: collapse">
                                                                <tr>
                                                                    <td align="right" style="padding-right: 10px; white-space: nowrap" valign="bottom">
                                                                        <asp:Label ID="Label14" runat="server" Font-Bold="True" Text="Tổng số lượng: "></asp:Label></td>
                                                                    <td align="right" colspan="2" style="width: 160px; border-bottom: black thin dotted;
                                                                        white-space: nowrap" valign="bottom">
                                                                        <asp:Label ID="lblQuantity" runat="server" Font-Names="tahoma" Font-Size="12px"></asp:Label></td>
                                                                    <td align="right" style="width: 2%; white-space: nowrap">
                                                                    </td>
                                                                    <td id="td1" runat="server" align="right" style="padding-right: 10px; white-space: nowrap"
                                                                        valign="bottom">
                                                                        <asp:Label ID="Label4" runat="server" Font-Bold="True" Text="Số tiền đã trả:"></asp:Label></td>
                                                                    <td id="td2" runat="server" align="right" style="width: 160px; border-bottom: black thin dotted;
                                                                        white-space: nowrap" valign="bottom">
                                                                        <asp:Label ID="lblRepaid" runat="server"></asp:Label>
                                                                        <asp:Label ID="Label9" runat="server" Text="VNĐ"></asp:Label>&nbsp;
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td align="right" style="padding-right: 10px; white-space: nowrap" valign="bottom">
                                                                        <asp:Label ID="Label15" runat="server" Font-Bold="True" Text="Tổng số tiền thanh toán: "></asp:Label></td>
                                                                    <td align="right" colspan="2" style="border-bottom: black thin dotted; white-space: nowrap"
                                                                        valign="bottom">
                                                                        <asp:Label ID="lblTotal" runat="server"></asp:Label>
                                                                        <asp:Label ID="Label6" runat="server" Text="VNĐ"></asp:Label></td>
                                                                    <td align="right" style="width: 2%; white-space: nowrap">
                                                                    </td>
                                                                    <td id="td3" runat="server" align="right" style="padding-right: 10px; white-space: nowrap"
                                                                        valign="bottom">
                                                                        <asp:Label ID="Label5" runat="server" Font-Bold="True" Text="Số tiền còn thiếu lại:"></asp:Label></td>
                                                                    <td id="td4" runat="server" align="right" style="border-bottom: black thin dotted;
                                                                        white-space: nowrap" valign="bottom">
                                                                        <asp:Label ID="lblRemainPrice" runat="server"></asp:Label>
                                                                        <asp:Label ID="Label11" runat="server" Text="VNĐ"></asp:Label>&nbsp;
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="left" valign="top">
                                                            <table border="0" cellpadding="0" cellspacing="0">
                                                                <tr>
                                                                    <td style="border-bottom: black thin dotted">
                                                                        <asp:Label ID="lblChuY" runat="server" Visible="false" Text="Ghi chú: " Font-Bold="true"></asp:Label>
                                                                        <asp:Label ID="lblNote" runat="server"></asp:Label></td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                                <br />
                            </td>
                        </tr>
                        <tr>
                            <td align="center" class="td_Content_Footer_590" style="padding-right: 25px">
                                &nbsp;<asp:Button ID="Button1" runat="server" CssClass="btn_Common" ForeColor="White" OnClick="Button1_Click"
                                    Text="Trở về giỏ hàng" />
                                <asp:Button ID="btnFinish" runat="server" CssClass="btn_Common" ForeColor="White"
                                    OnClick="btnFinish_Click" OnClientClick="IsPrintPage()" Text="Hoàn tất đặt hàng"
                                    ValidationGroup="grCustomer" /></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td align="center">
                    &nbsp;</td>
            </tr>
        </table>
    </div>
    <input type="hidden" id="hMethod" runat="server" />
    <input type="hidden" id="hUserExc" runat="server" />
    <input id="hPrintPage" runat="server" type="hidden" value="N" />

    <script language="javascript" type="text/javascript">
    function IsPrintPage()
    {
        var hPrintPage=document.getElementById("<%= hPrintPage.ClientID %>");
        if(confirm('Bạn có muốn in hóa đơn không???'))
            hPrintPage.value="S";
        else
            hPrintPage.value="N";
    }
    
   function fnAddUser()
    {
        var width=450;
        var height=450;
        var left = parseInt((screen.availWidth/2) - (width/2));
		var top = parseInt((screen.availHeight/2) - (height/2));		
        var feature="width="+width+",height="+height+",menu=0,scrollbars=1,status=1,location=0,resizable=1,left=" + left + ",top=20,screenX=" + left + ",screenY=" + top;
        var CodeID='<%= Request.QueryString["CodeID"]%>';
        window.open("../User/AddCustomer.aspx?Type=Admin&CodeID=" + CodeID ,"" ,feature)
    }
    function fnViewUser()
    {
        var width=750;
        var height=800;
        var left = parseInt((screen.availWidth/2) - (width/2));
		var top = parseInt((screen.availHeight/2) - (height/2));		
        var feature="width="+width+",height="+height+",menu=0,scrollbars=1,status=1,location=0,resizable=1,left=" + left + ",top=20,screenX=" + left + ",screenY=" + top;
        var CodeID='<%= Request.QueryString["CodeID"]%>';
        window.open("../User/ChooseUser.aspx?Type=NewCus&CodeID=" + CodeID ,"" ,feature)
    }
    function fnChooseUser(UserID)
    {
        var hUserExc=document.getElementById("<%= hUserExc.ClientID %>");
        hUserExc.value=UserID;
        var hMethod=document.getElementById("<%= hMethod.ClientID %>")   ;
        hMethod.value="<Method>CHOOSEUSER</Method><UserID>"+UserID+"</UserID>";

        var theform = document.forms["aspnetForm"];
		theform.submit();
    }
    
     /*=================Email================*/
    String.prototype.trim = function () {
		return this.replace(/^\s*/, "").replace(/\s*$/, "");
	}
    function fnHideImgEmail()
    {
        var imgStateEmail=document.getElementById("imgStateEmail");
        imgStateEmail.style.visibility="hidden"; 
    }
    function fnCheckEmail(sValue)
    {  
        if(sValue.trim()=="")  return;
        
        var hUserExc=document.getElementById("<%= hUserExc.ClientID %>");
        Manager_OrderApp_OrderDetailApp.AjaxCheckEmail(sValue,hUserExc.value,CallBackEmail);  
     
    }
    function CallBackEmail(res)
    {
        if(res!=null)
        {
            var flag=res.value;
            if(flag!=null && flag!="")
			{	
			    var imgStateEmail=document.getElementById("imgStateEmail");

			    var hidEmail=document.getElementById("<%= hidEmail.ClientID%>");
			    hidEmail.value="aaa"; //Tranh su kien dang su ly
		
			    if(flag=="yes")
			    {   imgStateEmail.style.visibility="visible";
			        imgStateEmail.src="../../Images/Icon/cmdDelete.gif";
			        imgStateEmail.alt="Email này đã tồn tại";			        
			        hidEmail.value="0";
			       
			    }		
			    else
			    {
			           imgStateEmail.style.visibility="hidden";
			    }	    
			}	
        }
    }
    
    
    </script>

</asp:Content>
